Skip to content

Conversation

@JMS55
Copy link
Contributor

@JMS55 JMS55 commented Jan 2, 2026

Objective

  • Greatly reduce light leaks near corners of objects (but doesn't fix general light leaks from tiny geometry)

Solution

To prevent light leaks:

  • When ray_t is smaller than the cache cell size, force the finest LOD cache access.
  • Make LOD much less aggressive
  • Make the finest LOD smaller

Since this then greatly increases the number of cache cells in the scene, I changed the following to prevent too much of a decrease in performance (this PR is still a hit to performance though):

  • Randomly skip updating some cells once we have more than 40,000 cells active
  • Aggressively prune older cache cells

Also some misc changes:

Ideally the skipped cells wouldn't be totally random, and we'd have coarser-LOD cells update less frequently, but that would get very complicated as we'd have to track the total amount of cells per LOD in order to average out to WORLD_CACHE_TARGET_CELL_UPDATES.

@JMS55 JMS55 marked this pull request as draft January 2, 2026 04:05
@JMS55 JMS55 requested a review from SparkyPotato January 2, 2026 04:05
@JMS55 JMS55 added A-Rendering Drawing game state to the screen C-Refinement Improves output quality, without fixing a clear bug or adding new functionality. labels Jan 2, 2026
@JMS55 JMS55 marked this pull request as ready for review January 11, 2026 20:02
@JMS55 JMS55 added the S-Needs-Review Needs reviewer attention (from anyone!) to move forward label Jan 11, 2026
@JMS55 JMS55 added this to the 0.19 milestone Jan 11, 2026
const WORLD_CACHE_POSITION_BASE_CELL_SIZE: f32 = 0.15;
/// How fast the world cache transitions between LODs as a function of distance to the camera
const WORLD_CACHE_POSITION_LOD_SCALE: f32 = 8.0;
const WORLD_CACHE_POSITION_LOD_SCALE: f32 = 15.0;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how hard will it be to make all these constants uniforms tweakable from Resource someday?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Easy, just not a priority atm. It's on the tracking issue.

Copy link
Contributor

@ChristopherBiscardi ChristopherBiscardi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The diagnostics are cool

Image

@JMS55 JMS55 added S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it and removed S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Jan 13, 2026
@alice-i-cecile alice-i-cecile added this pull request to the merge queue Jan 13, 2026
Merged via the queue into bevyengine:main with commit 042036b Jan 13, 2026
42 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Rendering Drawing game state to the screen C-Refinement Improves output quality, without fixing a clear bug or adding new functionality. S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

5 participants